﻿Imports System.Data.OleDb
Imports DTO
Public Class TraSach_ChiTietTraSachDAO
    Public Function LayDSPTS_CTPTSTheoMaDocGia(ByVal maDocgia As Integer) As List(Of TraSach_ChiTietTraSachDTO)
        DataProvider.OpenConnecttion()
        Dim sql As String = "SELECT PHIEUTRASACH.MaPhieuTraSach, PHIEUTRASACH.MaDocGia, PHIEUTRASACH.NgayTra, PHIEUTRASACH.TienPhatKyNay,"
        sql = sql & "  PHIEUTRASACH.TienNo, PHIEUTRASACH.TongNo, PHIEUTRASACH.MaChiTietPhieuTraSach, CHITIETPHIEUTRASACH.MaSach, "
        sql = sql & " CHITIETPHIEUTRASACH.NgayMuon, CHITIETPHIEUTRASACH.SoNgayMuon, CHITIETPHIEUTRASACH.TienPhat ,CHITIETPHIEUTRASACH.MaTheLoai,CHITIETPHIEUTRASACH.MaTacGia "
        sql = sql & " FROM CHITIETPHIEUTRASACH INNER JOIN PHIEUTRASACH ON CHITIETPHIEUTRASACH.MaChiTietPhieuTraSach = PHIEUTRASACH.MaChiTietPhieuTraSach "
        sql = sql & " WHERE (((PHIEUTRASACH.MaDocGia)=" & maDocgia.ToString() & ")); "
        Dim reader As OleDbDataReader = DataProvider.ExecSelect(sql)
        Dim ds As New List(Of TraSach_ChiTietTraSachDTO)

        While reader.Read()
            Dim item As New TraSach_ChiTietTraSachDTO()
            item.MaPhieu = reader.GetInt32(0)
            item.MaDocGia = reader.GetInt32(1)
            item.NgayTra = reader.GetDateTime(2)
            item.TienPhatKyNay = reader.GetInt32(3)
            item.TienNo = reader.GetInt32(4)
            item.TongNo = reader.GetInt32(5)
            item.MaChiTietPhieu = reader.GetInt32(6)
            item.MaSach = reader.GetInt32(7)
            item.NgayMuon = reader.GetDateTime(8)
            item.SoNgayMuon = reader.GetInt32(9)
            item.TienPhat = reader.GetInt32(10)
            item.MaTheLoai = reader.GetInt32(11)
            item.MaTacGia = reader.GetInt32(12)
            ds.Add(item)
        End While
        DataProvider.CloseConnect()
        Return ds
    End Function


End Class
